# -*- coding: utf8 -*-
'''
    1.3.4 直方图均衡化
'''

import os
from PIL import Image
from numpy import array, uint8
import imtool

infile = 'img/haizei.jpg'

# 读取图像到数组中
im = array(Image.open(infile).convert('L'))
outfile = os.path.splitext(infile)[0] + '1.3.4.jpg'

im2, cdf = imtool.histeq(im)
pil_im = Image.fromarray(uint8(im2))
pil_im.save(outfile)
